VERSION 5.00
Begin VB.Form frmClassFinder 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "LenSoft Inc. Window Manager"
   ClientHeight    =   6180
   ClientLeft      =   4455
   ClientTop       =   2700
   ClientWidth     =   5985
   Icon            =   "Window Class Finder.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   6180
   ScaleWidth      =   5985
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Command11 
      Caption         =   "Disable"
      Height          =   400
      Left            =   4320
      TabIndex        =   32
      Top             =   2640
      Width           =   840
   End
   Begin VB.CommandButton Command10 
      Caption         =   "Enable"
      Height          =   400
      Left            =   3480
      TabIndex        =   31
      Top             =   2640
      Width           =   840
   End
   Begin VB.Timer Timer1 
      Interval        =   1
      Left            =   2400
      Top             =   1560
   End
   Begin VB.CommandButton Command9 
      Caption         =   "Find"
      Height          =   400
      Left            =   2640
      TabIndex        =   30
      Top             =   2640
      Width           =   840
   End
   Begin VB.Timer Timer3 
      Enabled         =   0   'False
      Left            =   3840
      Top             =   1560
   End
   Begin VB.TextBox Text2 
      Height          =   285
      Left            =   1800
      MaxLength       =   2
      TabIndex        =   27
      Text            =   "60"
      Top             =   5880
      Width           =   495
   End
   Begin VB.CheckBox Check1 
      Caption         =   "Auto refresh every"
      Height          =   255
      Left            =   120
      TabIndex        =   26
      Top             =   5880
      Value           =   1  'Checked
      Width           =   1695
   End
   Begin VB.Timer Timer2 
      Enabled         =   0   'False
      Interval        =   2000
      Left            =   2880
      Top             =   1560
   End
   Begin VB.CommandButton Command8 
      Caption         =   "Move"
      Height          =   400
      Left            =   1800
      TabIndex        =   25
      Top             =   2640
      Width           =   840
   End
   Begin VB.CommandButton Command7 
      Caption         =   "Make invisible"
      Height          =   400
      Left            =   960
      TabIndex        =   24
      Top             =   2640
      Width           =   840
   End
   Begin VB.CommandButton Command6 
      Caption         =   "Putontop"
      Height          =   400
      Left            =   120
      TabIndex        =   23
      Top             =   2640
      Width           =   840
   End
   Begin VB.CommandButton Command5 
      Caption         =   "Set all Captions"
      Height          =   255
      Left            =   2040
      TabIndex        =   22
      Top             =   4440
      Width           =   3735
   End
   Begin VB.CommandButton Command4 
      Caption         =   "Set Caption"
      Height          =   255
      Left            =   2040
      TabIndex        =   21
      Top             =   4080
      Width           =   3735
   End
   Begin VB.TextBox Text1 
      Height          =   285
      Left            =   2040
      TabIndex        =   20
      Top             =   3600
      Width           =   3735
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Quit"
      Height          =   400
      Left            =   4320
      TabIndex        =   19
      Top             =   2160
      Width           =   840
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Minimize"
      Height          =   400
      Left            =   120
      TabIndex        =   18
      Top             =   2160
      Width           =   840
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Close"
      Height          =   400
      Left            =   960
      TabIndex        =   17
      Top             =   2160
      Width           =   840
   End
   Begin VB.CommandButton cmdRefreshClass 
      Caption         =   "Refresh Class"
      Height          =   400
      Left            =   1800
      TabIndex        =   16
      Top             =   2160
      Width           =   840
   End
   Begin VB.CommandButton cmdActivate 
      Caption         =   "&Activate"
      Height          =   400
      Left            =   2640
      TabIndex        =   9
      Top             =   2160
      Width           =   840
   End
   Begin VB.Timer tmrWinClass 
      Interval        =   60000
      Left            =   3360
      Top             =   1560
   End
   Begin VB.CommandButton cmdRefresh 
      Caption         =   "&Refresh"
      Height          =   400
      Left            =   3480
      TabIndex        =   4
      Top             =   2160
      Width           =   840
   End
   Begin VB.ListBox lstOpenWindows 
      Height          =   1620
      Left            =   120
      Sorted          =   -1  'True
      TabIndex        =   3
      Top             =   480
      Width           =   5820
   End
   Begin VB.CommandButton cmdGetClass 
      Caption         =   "Get &Class"
      Height          =   400
      Left            =   5160
      TabIndex        =   1
      Top             =   2160
      Width           =   840
   End
   Begin VB.TextBox txtTitle 
      Enabled         =   0   'False
      Height          =   285
      Left            =   105
      TabIndex        =   0
      Top             =   120
      Width           =   5820
   End
   Begin VB.Label lblHwnd 
      AutoSize        =   -1  'True
      Caption         =   "Hwnd:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00404040&
      Height          =   195
      Left            =   120
      TabIndex        =   29
      Top             =   4800
      Visible         =   0   'False
      Width           =   555
   End
   Begin VB.Label Label1 
      Caption         =   "seconds."
      Height          =   255
      Left            =   2400
      TabIndex        =   28
      Top             =   5880
      Width           =   735
   End
   Begin VB.Label lblRight 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00404040&
      Height          =   225
      Left            =   75
      TabIndex        =   15
      Top             =   4560
      Width           =   1860
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblBottom 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00404040&
      Height          =   225
      Left            =   75
      TabIndex        =   14
      Top             =   4080
      Width           =   1860
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblLeft 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00404040&
      Height          =   225
      Left            =   120
      TabIndex        =   13
      Top             =   4320
      Width           =   1860
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblTop 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00404040&
      Height          =   225
      Left            =   75
      TabIndex        =   12
      Top             =   3840
      Width           =   1860
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblProcessID 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00404040&
      Height          =   225
      Left            =   75
      TabIndex        =   11
      Top             =   3600
      Width           =   1860
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblCount 
      BackColor       =   &H00C0C0C0&
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   240
      Left            =   120
      TabIndex        =   10
      Top             =   3360
      Width           =   5625
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblClass 
      Caption         =   "Current Window Class:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00008000&
      Height          =   240
      Left            =   2040
      TabIndex        =   8
      Top             =   5520
      Width           =   3735
      WordWrap        =   -1  'True
   End
   Begin VB.Label Label3 
      Caption         =   "Current Window Class:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00008000&
      Height          =   240
      Left            =   120
      TabIndex        =   7
      Top             =   5520
      Width           =   1980
      WordWrap        =   -1  'True
   End
   Begin VB.Line Line1 
      X1              =   120
      X2              =   5760
      Y1              =   5160
      Y2              =   5160
   End
   Begin VB.Label Label2 
      Caption         =   "Current Window Title:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00008000&
      Height          =   225
      Left            =   90
      TabIndex        =   6
      Top             =   5280
      Width           =   1860
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblCurrent 
      Caption         =   "Current Window:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00008000&
      Height          =   360
      Left            =   2040
      TabIndex        =   5
      Top             =   5280
      Width           =   3735
      WordWrap        =   -1  'True
   End
   Begin VB.Label lblClassName 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   255
      Left            =   120
      TabIndex        =   2
      Top             =   3120
      Width           =   5625
      WordWrap        =   -1  'True
   End
End
Attribute VB_Name = "frmClassFinder"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'This is my new Window Manager, some bugs were fixed
'ability to Enable/Disable Windows added
'Created by Lennert Van Damme
'lennertvandamme@Hotmail.com

Private CurX As Double
Private CurY As Double
Const WM_SETTEXT = &HC
Private Declare Function CloseWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
        x As Long
        y As Long
End Type

Private Sub Check1_Click()
On Error Resume Next
Timer3.Interval = Text2.Text * 1000
Timer3.Enabled = Check1.Value
End Sub

Private Sub cmdGetClass_Click()
Dim lngHand As Long
Dim strName As String * 255
Dim wndClass As wndClass
Dim lngProcID As Long
Dim rctTemp As RECT
lngHand = FindWindow(vbNullString, txtTitle.Text)
GetClassName lngHand, strName, Len(strName)
If Left$(strName, 1) = vbNullChar Then
lblClassName.Caption = "Window Not Found!!!"
Else
lblClassName.Caption = "Class Name: " & strName
GetWindowThreadProcessId lngHand, lngProcID
GetWindowRect lngHand, rctTemp
End If
lblProcessID = "ProcessID: " & lngProcID
lblTop = "Top: " & rctTemp.Top
lblBottom = "Bottom: " & rctTemp.Bottom
lblLeft = "Left: " & rctTemp.Left
lblRight = "Right: " & rctTemp.Right
End Sub

Private Sub cmdRefresh_Click()
lstOpenWindows.Clear
lblCount.Caption = GetOpenWindowNames & " open Windows."
End Sub

Private Sub cmdActivate_Click()
Dim lngHand As Long
If Trim$(lblClassName.Caption) = "" Then
lngHand = FindWindow(vbNullChar, Trim$(txtTitle.Text))
Else
lngHand = FindWindow(Right$(lblClassName.Caption, (Len(lblClassName) - 12)), lstOpenWindows.Text)
End If
BringWindowToTop lngHand
End Sub

Private Sub cmdRefreshClass_Click()
Call cmdGetClass_Click
End Sub

Private Sub Command1_Click()
If txtTitle.Text = "Lennert Pro tm Window-manager V2.2" Or txtTitle.Text = "Window manager" Or txtTitle.Text = "Window manager" Then Exit Sub
killapp
End Sub


Private Sub Command10_Click()
Dim target_name As String
target_name = txtTitle.Text
thw = FindWindow(vbNullString, target_name)
EnableWindow thw, True
End Sub

Private Sub Command11_Click()
Dim target_name As String
target_name = txtTitle.Text
thw = FindWindow(vbNullString, target_name)
EnableWindow thw, False
End Sub

Private Sub Command2_Click()
If txtTitle.Text = "Lennert Pro tm Window-manager V2.2" Or txtTitle.Text = "Window manager" Or txtTitle.Text = "Window manager" Then Exit Sub
Dim target_name As String
target_name = txtTitle.Text
thw = FindWindow(vbNullString, target_name)
CloseWindow thw
End Sub

Private Sub Command3_Click()
Unload Me
End
End Sub

Private Sub Command4_Click()
If txtTitle.Text = "Lennert Pro tm Window-manager V2.2" Or txtTitle.Text = "Window manager" Or txtTitle.Text = "Window manager" Then Exit Sub
Dim target_hwnd As Long
Dim target_name As String
Dim new_caption As String
target_name = txtTitle.Text
target_hwnd = FindWindow(vbNullString, target_name)
If target_hwnd = 0 Then
Exit Sub
End If
new_caption = Text1.Text
SendMessage target_hwnd, _
WM_SETTEXT, 0, _
ByVal new_caption
cmdRefresh_Click
End Sub

Private Sub Command5_Click()
lstOpenWindows.ListIndex = 0
For i% = 1 To lstOpenWindows.ListCount - 1
lstOpenWindows.ListIndex = lstOpenWindows.ListIndex + 1
Dim target_hwnd As Long
Dim target_name As String
Dim new_caption As String
target_name = txtTitle.Text
target_hwnd = FindWindow(vbNullString, target_name)
If target_hwnd = 0 Then
Exit Sub
End If
new_caption = Text1.Text
SendMessage target_hwnd, _
WM_SETTEXT, 0, _
ByVal new_caption
Next i%
cmdRefresh_Click
'Me.Caption = "Lennert Pro tm Window-manager V2.1"
End Sub

Private Sub Command6_Click()
Dim target_name As String
target_name = txtTitle.Text
thw = FindWindow(vbNullString, target_name)
SetWindowPos thw, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
End Sub

Private Sub Command7_Click()
Dim target_name As String
target_name = txtTitle.Text
thw = FindWindow(vbNullString, target_name)
SetWindowPos thw, HWND_RESIZE, 8000, 8000, 0, 0, SWP_MOVE Or SWP_SIZE
End Sub

Private Sub Command8_Click()
MsgBox "The selected window will be moved in 2 sec after you click 'OK'" & Chr(13) & "The window will be moved to were you're cursor is located." & Chr(13) & "P.S: Due to a minor bug, the window will be resized, sorry.", vbApplicationModal, "Window manager"
Timer2.Enabled = True
End Sub


Private Sub Command9_Click()
Dim wFind, wResult
wFind = InputBox("Enter Window text:")
If wFind = "" Then Exit Sub
wResult = FindWindow(vbNullString, wFind)
MsgBox wResult
End Sub

Private Sub Form_Load()
'SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE
txtTitle.SelLength = Len(txtTitle.Text)
lblCount.Caption = GetOpenWindowNames & " open Windows."
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
CurX = x
CurY = y
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then 'use mouse_left_button
   Me.Move Me.Left + (x - CurX), Me.Top + (y - CurY)
End If
End Sub

Private Sub lstOpenWindows_Click()
Timer1.Enabled = True
lblHwnd.Visible = True
txtTitle.Text = lstOpenWindows.Text
Call cmdGetClass_Click
End Sub

Private Sub Text2_Change()
On Error Resume Next
Timer3.Interval = Text2.Text * 1000
End Sub

Private Sub Timer1_Timer()
Timer1.Enabled = False
lblHwnd.Caption = "Hwnd: " & FindWindow(vbNullString, frmClassFinder.txtTitle.Text)
End Sub

Private Sub Timer2_Timer()
Timer2.Enabled = False
Dim a As POINTAPI
GetCursorPos a
Dim target_name As String
target_name = txtTitle.Text
thw = FindWindow(vbNullString, target_name)
'SetWindowPos thw, HWND_RESIZE, a.X, a.Y, 0, 0, SWP_MOVE Or SWP_SIZE
SetWindowPos thw, HWND_MOVE, a.x, a.y, 500, 500, SWP_MOVE Or SWP_MOVE
End Sub

Private Sub Timer3_Timer()
cmdRefresh_Click
End Sub

Private Sub tmrWinClass_Timer()
Dim lngHand As Long
Dim strName As String * 255
lngHand = GetForegroundWindow
GetWindowText lngHand, strName, Len(strName)
lblCurrent.Caption = strName
GetClassName lngHand, strName, Len(strName)
lblClass.Caption = strName
End Sub
